<?php
require_once 'seitcm_resize_image.php';
$file = '../cover/' . basename($_FILES['uploadfile']['name']); 
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
	$fileresize = md5(rand_string(20)) . '.jpg';
	$image = new SimpleImage();
	$image->load($file);
	$image->resize(300,400);
	$image->save('../cover/' . $fileresize);
	unlink($file);
  	echo $fileresize; 
} else {
	echo "error";
}

function rand_string($length) {
	$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	$size = strlen($chars);
	$str = '';
	for($i = 0; $i < $length; $i++) {
		$str .= $chars[rand(0, $size - 1)];
	}
	return $str;
}
?>